package com.example.hotdeploy.service.impl;

import com.example.hotdeploy.Call;
import com.example.hotdeploy.hot.HotDeployFactory;
import com.example.hotdeploy.service.FeeService;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.math.BigDecimal;

/**
 * @Description: 计费实现逻辑
 * @Author: kai.yang
 * @Date: 2019-03-10 07:08
 */
@Component
public class FeeServiceImpl implements FeeService {

    private static final String CallClass="TestCall";

    static{
        HotDeployFactory.init("TestCall");
    }



    @Override
    public String callUserFee(BigDecimal amount, String feeRate) throws Exception {
        Object object = HotDeployFactory.getObject(CallClass);
        Method call = object.getClass().getMethod("call", BigDecimal.class, String.class);
        Object invoke = call.invoke(object, amount, feeRate);
        return invoke.toString();
    }
}
